package com.leyou.search.dto;

import java.util.Map;

/**
 * 接收前端发送的搜索的参数数据
 */
public class SearchRequest {
    private String key;   //搜索条件
    private Integer page;    //当前页码
    private static final Integer DEFAULT_PAGE = 1;   //默认页码
    private static final Integer DEFAULT_SIZE = 20;  //默认页面大小

    private Map<String,String> filters;  //过滤项

    public Map<String, String> getFilters() {
        return filters;
    }

    public void setFilters(Map<String, String> filters) {
        this.filters = filters;
    }


    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    //对当前页码进行校验,不能小于1
    public Integer getPage() {
        if (null == page) {
            return DEFAULT_PAGE;
        }
        return page > 1 ? page : DEFAULT_PAGE;
    }

    public void setPage(Integer page) {

        this.page = page;
    }

    public Integer getSize() {
        return DEFAULT_SIZE;
    }
}
